<style type="text/css">
    
    .left-home .box-left div table th, .left-home .box-left div table td {
        padding-right: 10px !important
    }
    
</style>

<div class="client-home">
    <div class="menu">
        {if $smarty.session.user.clients|@count > 1}
            <form action="{$data.root}?input=main" id="clientHomeForm" method="post">
                <select name="client" size="1" onchange="submitForm('clientHomeForm')">
                    {foreach from=$smarty.session.user.clients item="client"}
                        <option {if $client == $smarty.session.home_client}selected="selected"{/if} value="{$client}">{getClientName id=$client}</option>
                    {/foreach}
                </select>
            </form>
        {/if}
    </div>
    <h1>
        {$data.client_data.fullName}
    </h1>
    <div class="left-home">
        <div class="box-left">
            <div>
                <h4>
                    Timesheet records - {$data.date1}
                </h4>
                <table>
                    <tr>
                        <th>Date</th>
                        <th>Description</th>
                        <th>Type of record</th>
                        <th>Amount</th>
                        <th>Tariff</th>
                        <th>Unit price</th>
                        <th>Added by</th>
                    </tr>
                    {foreach from=$data.records_current item="record"}
                        <tr>
                            <td>
                                {$record.date_formated}
                            </td>
                            <td>
                                {$record.description}
                            </td>
                            <td>
                                {$record.type_info.type_of_record}
                            </td>
                            <td>
                                {$record.amount}
                            </td>
                            <td>
                                {$record.tariff_info.title}
                            </td>
                            <td>
                                {$record.unit_price}
                            </td>
                            <td>
                                {if $record.user_info.users_id!=0}
                                    {$record.user_info.name} {$record.user_info.surname}
                                {else}
                                    -
                                {/if}
                            </td>
                        </tr>
                    {/foreach}
                    <tr>
                        <th colspan="7">&nbsp;</th>
                    </tr>
                    <tr>
                        <td colspan="3"><b>Total:</b></td>
                        <td colspan="4"><b>{$data.current_sum}</b></td>
                    </tr>
                    <tr>
                        <td style="border-bottom: 1px solid #066" colspan="3">Prepaid monthly range:</td>
                        <td style="border-bottom: 1px solid #066" colspan="4">{$data.client_data.monthlyPrepaid}</td>
                    </tr>
                    <tr>
                        <th style="color: #066; border-bottom: 0px solid white" colspan="3">Overrange:</th>
                        <th style="color: #066; border-bottom: 0px solid white" colspan="4">{$data.overrange}</th>
                    </tr>
                </table>
            </div>
        </div>
        {if !empty($data.goods_current)}
        <div class="box-left">
            <div>
                <h4>
                    Delivery of goods - {$data.date1}
                </h4>
                <table>
                    <tr>
                        <th>Date</th>
                        <th>Description</th>
                        <th>Type of record</th>
                        <th>Amount</th>
                        <th>Tariff</th>
                        <th>Unit price</th>
                        <th>Added by</th>
                    </tr>
                    {foreach from=$data.goods_current item="record"}
                        <tr>
                            <td>
                                {$record.date_formated}
                            </td>
                            <td>
                                {$record.description}
                            </td>
                            <td>
                                {$record.type_info.type_of_record}
                            </td>
                            <td>
                                {$record.amount}
                            </td>
                            <td>
                                {$record.tariff_info.title}
                            </td>
                            <td>
                                {$record.unit_price}
                            </td>
                            <td>
                                {if $record.user_info.users_id!=0}
                                    {$record.user_info.name} {$record.user_info.surname}
                                {else}
                                    -
                                {/if}
                            </td>
                        </tr>
                    {/foreach}
                    <tr>
                        <th colspan="7">&nbsp;</th>
                    </tr>
                    <tr>
                        <td colspan="3"><b>Total:</b></td>
                        <td colspan="4"><b>{$data.current_goods_sum}</b></td>
                    </tr>
                </table>
            </div>
        </div>
        {/if}
        
        {if !empty($data.transport_current)}
        <div class="box-left">
            <div>
                <h4>
                    Transport fee - {$data.date1}
                </h4>
                <table>
                    <tr>
                        <th>Date</th>
                        <th>Description</th>
                        <th>Type of record</th>
                        <th>Amount</th>
                        <th>Tariff</th>
                        <th>Unit price</th>
                        <th>Added by</th>
                    </tr>
                    {foreach from=$data.transport_current item="record"}
                        <tr>
                            <td>
                                {$record.date_formated}
                            </td>
                            <td>
                                {$record.description}
                            </td>
                            <td>
                                {$record.type_info.type_of_record}
                            </td>
                            <td>
                                {$record.amount}
                            </td>
                            <td>
                                {$record.tariff_info.title}
                            </td>
                            <td>
                                {$record.unit_price}
                            </td>
                            <td>
                                {if $record.user_info.users_id!=0}
                                    {$record.user_info.name} {$record.user_info.surname}
                                {else}
                                    -
                                {/if}
                            </td>
                        </tr>
                    {/foreach}
                    <tr>
                        <th colspan="7">&nbsp;</th>
                    </tr>
                    <tr>
                        <td colspan="3"><b>Total:</b></td>
                        <td colspan="4"><b>{$data.current_transport_sum}</b></td>
                    </tr>
                </table>
            </div>
        </div>
        {/if}

        <div class="box-left">
            <div>
                <h4>
                    Timesheet records - {$data.date2}
                </h4>
                <table>
                    <tr>
                        <th>Date</th>
                        <th>Description</th>
                        <th>Type of record</th>
                        <th>Amount</th>
                        <th>Tariff</th>
                        <th>Unit price</th>
                        <th>Added by</th>
                    </tr>
                    {foreach from=$data.records_last item="record"}
                        <tr>
                            <td>
                                {$record.date_formated}
                            </td>
                            <td>
                                {$record.description}
                            </td>
                            <td>
                                {$record.type_info.type_of_record}
                            </td>
                            <td>
                                {$record.amount}
                            </td>
                            <td>
                                {$record.tariff_info.title}
                            </td>
                            <td>
                                {$record.unit_price}
                            </td>
                            <td>
                                {if $record.user_info.users_id!=0}
                                    {$record.user_info.name} {$record.user_info.surname}
                                {else}
                                    -
                                {/if}
                            </td>
                        </tr>
                    {/foreach}
                    <tr>
                        <th colspan="7">&nbsp;</th>
                    </tr>
                    <tr>
                        <td colspan="3" style="border-bottom: 0px solid white;"><b>Total:</b></td>
                        <td colspan="4" style="border-bottom: 0px solid white;"><b>{$data.last_sum}</b></td>
                    </tr>

                </table>
            </div>
        </div>

        {if !empty($data.goods_last)}
        <div class="box-left">
            <div>
                <h4>
                    Delivery of goods - {$data.date2}
                </h4>
                <table>
                    <tr>
                        <th>Date</th>
                        <th>Description</th>
                        <th>Type of record</th>
                        <th>Amount</th>
                        <th>Tariff</th>
                        <th>Unit price</th>
                        <th>Added by</th>
                    </tr>
                    {foreach from=$data.goods_last item="record"}
                        <tr>
                            <td>
                                {$record.date_formated}
                            </td>
                            <td>
                                {$record.description}
                            </td>
                            <td>
                                {$record.type_info.type_of_record}
                            </td>
                            <td>
                                {$record.amount}
                            </td>
                            <td>
                                {$record.tariff_info.title}
                            </td>
                            <td>
                                {$record.unit_price}
                            </td>
                            <td>
                                {if $record.user_info.users_id!=0}
                                    {$record.user_info.name} {$record.user_info.surname}
                                {else}
                                    -
                                {/if}
                            </td>
                        </tr>
                    {/foreach}
                    <tr>
                        <th colspan="7">&nbsp;</th>
                    </tr>
                    <tr>
                        <td colspan="3" style="border-bottom: 0px solid white;"><b>Total:</b></td>
                        <td colspan="4" style="border-bottom: 0px solid white;"><b>{$data.last_goods_sum}</b></td>
                    </tr>

                </table>
            </div>
        </div>
        {/if}
                    
        {if !empty($data.transport_last)}
        <div class="box-left">
            <div>
                <h4>
                    Transport fee - {$data.date2}
                </h4>
                <table>
                    <tr>
                        <th>Date</th>
                        <th>Description</th>
                        <th>Type of record</th>
                        <th>Amount</th>
                        <th>Tariff</th>
                        <th>Unit price</th>
                        <th>Added by</th>
                    </tr>
                    {foreach from=$data.transport_last item="record"}
                        <tr>
                            <td>
                                {$record.date_formated}
                            </td>
                            <td>
                                {$record.description}
                            </td>
                            <td>
                                {$record.type_info.type_of_record}
                            </td>
                            <td>
                                {$record.amount}
                            </td>
                            <td>
                                {$record.tariff_info.title}
                            </td>
                            <td>
                                {$record.unit_price}
                            </td>
                            <td>
                                {if $record.user_info.users_id!=0}
                                    {$record.user_info.name} {$record.user_info.surname}
                                {else}
                                    -
                                {/if}
                            </td>
                        </tr>
                    {/foreach}
                    <tr>
                        <th colspan="7">&nbsp;</th>
                    </tr>
                    <tr>
                        <td colspan="3" style="border-bottom: 0px solid white;"><b>Total:</b></td>
                        <td colspan="4" style="border-bottom: 0px solid white;"><b>{$data.last_transport_sum}</b></td>
                    </tr>

                </table>
            </div>
        </div>
        {/if}
    </div>
    <div class="right-home">

        <div class="box-right">
            <div>
                <h4>
                    Terms
                </h4>
                <p>
                    {$data.client_data.conditions}
                </p>
                <h4>
                    Users
                </h4>
                <ul>
                    {foreach from=$data.client_users item="user"}
                        <li>
                            <a class="baseLink" href="{$data.root}?input=edit_user&user={$user.users_id}">{$user.name} {$user.surname}</a>
                        </li>
                    {/foreach}
                </ul>
                <h4>
                    Type of cooperation
                </h4>
                <p>
                    {if isset($data.type_of_coop.type)}
                        {$data.type_of_coop.type}
                    {else}
                        Unfill
                    {/if}
                </p>
            </div>
        </div>



        <div class="box-right">
            <div>
                <h4>
                    Contact in AC
                </h4>
                <ul>
                    {if $data.contact_user.surname != ''}
                        <li>{$data.contact_user.name} {$data.contact_user.surname}</li>
                        <li><a href="mailto: {$data.contact_user.email}" class="baseLink">{$data.contact_user.email}</a></li>
                        {if $data.contact_user.telephone != null && $data.contact_user.telephone != ''}
                            <li>{$data.contact_user.telephone}</li>
                        {/if}
                    {else}
                        <li>Unfill</li>
                    {/if}
                </ul>
            </div>
        </div>
    </div>

    <div class="clear"></div>

    <div class="full-home">
        <div>
            <h4>
                Active tasks
            </h4>
            <table>
                <tr>
                    <th>Name</th>
                    <th>Added by</th>
                    <th>Added on</th>
                    <th>Deadline</th>
                    <th>Responsible</th>
                    <th>Worker</th>
                </tr>
                {foreach from=$data.tasks item="task"}
                    <tr>
                        <td>{$task.title}</td>
                        <td>{$task.creator_info.name} {$task.creator_info.surname}</td>
                        <td>{$task.created_format}</td>
                        <td>{$task.deadline_format}</td>
                        <td>{$task.responsible_info.name} {$task.responsible_info.surname}</td>
                        <td>
                            {if $task.worker!=-1}
                                {$task.worker_info.name} {$task.worker_info.surname}
                            {else}
                                -
                            {/if}
                        </td>
                    </tr>
                {/foreach}
            </table>
        </div>
    </div>

</div>